<template>
    <div class="app-container">
      <div class="block">
        <el-row  :gutter="24">

          <el-col :span="4">
            <el-input v-model="listQuery.mobile" placeholder="手机号"></el-input>
          </el-col>
          <el-col :span="4">
            <el-input v-model="listQuery.name" placeholder="姓名"></el-input>
          </el-col>
          <el-col :span="4">
            <el-input v-model="listQuery.cardNo" placeholder="证件号"></el-input>
          </el-col>
          <el-col :span="8">
            <el-button type="success" icon="el-icon-search" @click.native="search">{{ $t('button.search') }}</el-button>
            <el-button type="primary" icon="el-icon-refresh" @click.native="reset">{{ $t('button.reset') }}</el-button>
          </el-col>
        </el-row>
        <br>
      </div>


        <div class="block">
            <el-row>
                <el-col :span="24">
                    <el-button type="success" icon="el-icon-plus" @click.native="add">{{ $t('button.add') }}</el-button>
                    <el-button type="primary" icon="el-icon-edit" @click.native="edit">{{ $t('button.edit') }}</el-button>
                    <el-button type="danger" icon="el-icon-delete" @click.native="remove">{{ $t('button.delete') }}</el-button>
                </el-col>
            </el-row>
        </div>


        <el-table :data="list" v-loading="listLoading" element-loading-text="Loading" border fit highlight-current-row
                  @current-change="handleCurrentChange">
          <el-table-column type="expand">
            <template slot-scope="props">
              <el-form label-position="right" inline class="guns-table-expand">
                <el-form-item label="身份证注册地" >
                  <span>{{ props.row.registeAddr }}</span>
                </el-form-item>
                <el-form-item label="紧急联系人" >
                  <span>{{ props.row.contactsName }}</span>
                </el-form-item>
                <el-form-item label="联系人电话号" >
                  <span>{{ props.row.contactsTel }}</span>
                </el-form-item>
                <el-form-item label="电子邮件" >
                  <span>{{ props.row.email }}</span>
                </el-form-item>
                <el-form-item label="微信号" >
                  <span>{{ props.row.wx }}</span>
                </el-form-item>
                <el-form-item label="QQ号" >
                  <span>{{ props.row.qq }}</span>
                </el-form-item>
                <el-form-item label="座机号" >
                  <span>{{ props.row.homeTel }}</span>
                </el-form-item>
                <el-form-item label="证件正面照" v-if="props.row.cardFrontFileId > 0">
                  <a :href="props.row.cardFrontFileUrl" target="_blank" class="button" style="color:blue">点击打开</a>
                </el-form-item>
                <el-form-item label="证件反面照"  v-if="props.row.cardBackFileId > 0">
                  <a :href="props.row.cardBackFileUrl" target="_blank" class="button" style="color:blue">点击打开</a>
                </el-form-item>
                <el-form-item label="合同文件"  v-if="props.row.contractFileId > 0">
                  <a :href="props.row.contractFileUrl" target="_blank" class="button" style="color:blue">点击打开</a>
                </el-form-item>
                <el-form-item label="入住日期" >
                  <span>{{ props.row.inDateStr }}</span>
                </el-form-item>
                <el-form-item label="搬离日期" >
                  <span>{{ props.row.outDateStr }}</span>
                </el-form-item>
              </el-form>
            </template>
          </el-table-column>
          <el-table-column label="手机号" prop="mobile" width="130" align="center">
          </el-table-column>
          <el-table-column label="姓名" prop="name" align="center">
          </el-table-column>
          <el-table-column label="性别" prop="genderName" align="center">
          </el-table-column>
          <el-table-column label="证件类型" prop="cardTypeName" align="center">
          </el-table-column>
          <el-table-column label="证件号码" prop="cardNo" width="170" align="center" >
          </el-table-column>
          <el-table-column label="客户类型" prop="ownerFlagName" align="center">
          </el-table-column>
          <el-table-column label="状态" prop="stateName" align="center">
            <template slot-scope="scope">
              <span style="color:blue;" v-if="scope.row.state===1">{{scope.row.stateName}}</span>
              <span style="color:red;" v-if="scope.row.state===0">{{scope.row.stateName}}</span>
            </template>
          </el-table-column>
          <el-table-column label="操作" width="250" align="center">
            <template slot-scope="scope">
              <el-button type="info" icon="el-icon-log" size="mini" @click.native="docMng(scope.row.id)">资料</el-button>
              <el-button type="danger" icon="el-icon-log" size="mini" @click.native="disable(scope.row.id)">搬离</el-button>
              <el-button type="success" icon="el-icon-log" size="mini" @click.native="disable(scope.row.id)">房产</el-button>
            </template>
          </el-table-column>
        </el-table>

        <el-pagination
                background
                layout="total, sizes, prev, pager, next, jumper"
                :page-sizes="[10, 20, 50, 100,500]"
                :page-size="listQuery.limit"
                :total="total"
                @size-change="changeSize"
                @current-change="fetchPage"
                @prev-click="fetchPrev"
                @next-click="fetchNext">
        </el-pagination>

        <el-dialog
                :title="formTitle"
                :visible.sync="formVisible"
                width="70%">
            <el-form ref="form" :model="form" :rules="rules" label-width="150px">
                <el-row>
                    <el-col :span="12" >
                        <el-form-item label="手机号" prop="mobile" v-show="isAdd">
                            <el-input v-model.number="form.mobile" minlength=1 ></el-input>
                        </el-form-item>
                        <el-form-item label="手机号"  v-show="!isAdd">
                            {{form.mobile}}
                        </el-form-item>
                    </el-col>
                    <el-col :span="12">
                      <el-form-item label="姓名" prop="name" >
                        <el-input v-model="form.name" minlength=1></el-input>
                      </el-form-item>
                    </el-col>
                    <el-col :span="12">
                        <el-form-item label="证件类型" prop="cardType" >
                            <el-select v-model="form.cardType" placeholder="请选择">
                              <el-option
                                v-for="item in options.cardType"
                                :key="item.k"
                                :label="item.v"
                                :value="item.k">
                              </el-option>
                            </el-select>
                        </el-form-item>
                    </el-col>
                    <el-col :span="12">
                        <el-form-item label="证件号码" prop="cardNo" >
                            <el-input v-model="form.cardNo" minlength=1></el-input>
                        </el-form-item>
                    </el-col>
                    <el-col :span="12">
                        <el-form-item label="性别"  >
                            <el-select v-model="form.gender" placeholder="请选择">
                              <el-option
                                v-for="item in options.gender"
                                :key="item.k"
                                :label="item.v"
                                :value="item.k">
                              </el-option>
                            </el-select>
                        </el-form-item>
                    </el-col>
                    <el-col :span="12">
                        <el-form-item label="身份证注册地"  >
                            <el-input v-model="form.registeAddr" minlength=1></el-input>
                        </el-form-item>
                    </el-col>
                    <el-col :span="12">
                        <el-form-item label="紧急联系人"  >
                            <el-input v-model="form.contactsName" minlength=1></el-input>
                        </el-form-item>
                    </el-col>
                    <el-col :span="12">
                        <el-form-item label="联系人电话号"  >
                            <el-input v-model="form.contactsTel" minlength=1></el-input>
                        </el-form-item>
                    </el-col>
                    <el-col :span="12">
                        <el-form-item label="客户类型"  >
                            <el-select v-model="form.ownerFlag" placeholder="请选择">
                              <el-option
                                v-for="item in options.ownerFlag"
                                :key="item.k"
                                :label="item.v"
                                :value="item.k">
                              </el-option>
                            </el-select>
                        </el-form-item>
                    </el-col>
                    <el-col :span="12">
                        <el-form-item label="电子邮件"  >
                            <el-input type="mail" v-model="form.email" minlength=1></el-input>
                        </el-form-item>
                    </el-col>
                    <el-col :span="12">
                        <el-form-item label="微信号"  >
                            <el-input v-model="form.wx" minlength=1></el-input>
                        </el-form-item>
                    </el-col>
                    <el-col :span="12">
                        <el-form-item label="QQ号"  >
                            <el-input v-model="form.qq" minlength=1></el-input>
                        </el-form-item>
                    </el-col>

                    <!--
                    <el-col :span="12">
                        <el-form-item label="座机号"  >
                            <el-input v-model="form.homeTel" minlength=1></el-input>
                        </el-form-item>
                    </el-col>
                    <el-col :span="12">
                        <el-form-item label="证件正面照"  >
                            <el-input v-model="form.cardFrontFileId" minlength=1></el-input>
                        </el-form-item>
                    </el-col>
                    <el-col :span="12">
                        <el-form-item label="证件反面照"  >
                            <el-input v-model="form.cardBackFileId" minlength=1></el-input>
                        </el-form-item>
                    </el-col>
                    <el-col :span="12">
                        <el-form-item label="合同文件"  >
                            <el-input v-model="form.contractFileId" minlength=1></el-input>
                        </el-form-item>
                    </el-col>
                    <el-col :span="12">
                        <el-form-item label="状态"  >
                            <el-select v-model="form.state" placeholder="请选择">
                              <el-option
                                v-for="item in options.state"
                                :key="item.k"
                                :label="item.v"
                                :value="item.k">
                              </el-option>
                            </el-select>
                        </el-form-item>
                    </el-col>
                    -->
                    <el-col :span="12">
                        <el-form-item label="入住日期"  >
                            <el-date-picker type="date" placeholder="选择日期" v-model="form.inDate" style="width: 100%;">

                            </el-date-picker>
                        </el-form-item>
                    </el-col>
                    <el-col :span="12">
                        <el-form-item label="搬离日期"  >
                          <el-date-picker type="date" placeholder="选择日期" v-model="form.outDate" style="width: 100%;">

                          </el-date-picker>
                        </el-form-item>
                    </el-col>
                </el-row>
                <el-form-item>
                    <el-button type="primary" @click="save">{{ $t('button.submit') }}</el-button>
                    <el-button @click.native="formVisible = false">{{ $t('button.cancel') }}</el-button>
                </el-form-item>

            </el-form>
        </el-dialog>


      <el-dialog
        :title="docFormTitle"
        :visible.sync="docFormVisible"
        width="70%">
        <el-form ref="form" :model="form" :rules="rules" label-width="150px">
          <el-row>
            <el-col :span="24">
              <el-form-item label="身份证正面照">
                <el-upload
                  class="upload-demo"
                  accept="image/*"
                  drag
                  :action="docForm.cardFrontFileId"
                  :before-upload="handleBeforeUpload"
                  :on-success="handleUploadSuccess"
                >
                  <i class="el-icon-upload"></i>
                  <div class="el-upload__text">上传图片</div>
                </el-upload>
              </el-form-item>
            </el-col>
            <el-col :span="24">
              <el-form-item label="身份证反面照">
                <el-upload
                  class="upload-demo"
                  drag
                  :action="docForm.cardBackFileUrl"
                  :before-upload="handleBeforeUpload"
                  :on-success="handleUploadSuccess"
                >
                  <i class="el-icon-upload"></i>
                  <div class="el-upload__text">上传图片</div>
                </el-upload>
              </el-form-item>
            </el-col>
          </el-row>
          <el-form-item>
            <el-button type="primary" @click="save">{{ $t('button.submit') }}</el-button>
            <el-button @click.native="docFormVisible = false">{{ $t('button.cancel') }}</el-button>
          </el-form-item>

        </el-form>
      </el-dialog>
    </div>
</template>

<script src="./cust_info.js"></script>


<style rel="stylesheet/scss" lang="scss" scoped>
    @import "src/styles/common.scss";
</style>

